#!/bin/bash

echo "#### start compile"

rm -rf /usr/local/out_igh
mkdir -p /usr/local/out_igh/

make clean ; make distclean
chmod +x bootstrap ; ./bootstrap
export PATH="/home/zqj/environment/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/bin/:$PATH"
export CC=arm-linux-gnueabihf-gcc
export CXX=arm-linux-gnueabihf-g++
export AR=arm-linux-gnueabihf-ar
export LD=arm-linux-gnueabihf-ld
export RANLIB=arm-linux-gnueabihf-ranlib
export STRIP=arm-linux-gnueabihf-strip

./configure \
    --prefix=/usr/local/out_igh/ \
    --with-linux-dir=/home/zqj/1git_code/imx6ull_dual_system/kernel/ \
    --enable-8139too=no \
    --host=arm-linux-gnueabihf \
    --target=arm-linux-gnueabihf \
    --enable-generic=yes \
    --enable-fec-emac=yes
    # --enable-sunxi-gmac=no \
    # --enable-kernel \
    # --enable-rtmutex \
    # --disable-hrtimer \
    # --disable-eoe \

# 脚本内部禁止使用 sudo, 会重置环境变量 
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j8
make install -j8
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- modules -j8


mkdir -p /usr/local/out_igh/driver
cp ./devices/*.ko /usr/local/out_igh/driver
cp ./master/*.ko /usr/local/out_igh/driver
cp ./examples/mini/*.ko /usr/local/out_igh/driver

cp install_igh_to_imx6ull.sh /usr/local/out_igh/
chmod +x /usr/local/out_igh/install_igh_to_imx6ull.sh
sudo rm /usr/local/out_igh.zip
cd /usr/local
zip -r /usr/local/out_igh.zip ./out_igh/*
cd -
cp /usr/local/out_igh.zip /mnt/hgfs/0VMware_share/0.jinzhoushukong_update_package/
